package com.jinke.api.modules.app.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum OrderStatus {

    //1.已收到，2.传输中，3.已交付，4.已作废，5.失败
    DRAFT(0, "草稿"),
    RECENT(1, "待运输"),
    IN_TRANSIT(2, "运输中"),
    InfoReceived(7, "预上网"),
    DELIVERED(3, "已完成"),
    CANCEL(4, "已取消"),
    FAILURE(5, "失败"),
    CANCEL_ING(6, "取消中"),
    //CANCEL2(14, "取消中&已作废"),
    VOIDED(15, "已作废"),
    CANCEL_REJECT(16, "已拒绝"),
    ORDER_PLAY(17,"下单中"),
    ORDER_PRE_SUC(18,"预报成功")
    ;
    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;
    OrderStatus(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static OrderStatus defaultEnum(int value) {
        for (OrderStatus type : OrderStatus.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("No element matches " + value);
    }
}